// https : // iai.sh.cn/problem/739
#include <bits/stdc++.h>
using namespace std;
long long a[200001];
int main() {
  int n;
  cin >> n;
  for (int i = 1; i <= n; i++) {
    cin >> a[i];
  }
  sort(a + 1, a + n + 1);
  long long ans = 0;

  for (int i = 1; i <= n; i++) {
    long long price = a[i] * (n - i + 1);
    if (price > ans) {
      ans = price;
    }
  }
  cout << ans << endl;
}
